package com.myway.service.ibe.command;

import com.travelsky.ebuild.clientapi.axi.FareRule;
import com.travelsky.ebuild.clientapi.axi.POSType;
import com.travelsky.ebuild.clientapi.axi.RuleRequest;
import com.travelsky.ebuild.clientapi.axi.RuleResult;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by yufei on 2018/7/7.
 */
public class FarRuleCommand extends BaseIBECommand {


    public void execute() throws ParseException {
        try{
            FareRule rule = new FareRule();

            POSType pos = this.configIBEClientPrice(rule);

            RuleRequest request = new RuleRequest();

            request.setFareReference("TSTOW");

            request.setDepartureAirport("TBS");

            request.setArrivalAirport("HRK");

            request.setFilingAirline("MJ");

            request.setRef1("GEPY01(USER(TBS,'1E',&lt;&gt;,Y,DEPT(&lt;&gt;,&lt;&gt;),&lt;&gt;,&lt;&gt;,&lt;&gt;),PF2(Y,[(AGENCY(TBS319),IATANUM('10003195'),N)],[''],[],[],N,&lt;&gt;),&lt;&gt;)");

            request.setRef2("421MTH1EHNADTY0088000100SITA");

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String s = "2018-10-20";
            Date date = sdf.parse(s);

            request.setDepartureDate(date);

            request.setFareCurrencySelection("EUR");
            request.setPos(pos);

            RuleResult result = rule.getRuleInfo(request);

            String fil = result.getFilingAirline();

        }catch(Exception e){
            e.printStackTrace();;
        }
    }


}
